<template>
	<!-- 页面标题 -->
	<div class="flex">
		<Breadcrumb :breadCrumb="breadCrumb"></Breadcrumb>
	</div>
	<!-- 搜索框 -->
	<ComSearch @handle-search="handleSearch" v-if="showSearch" ref="ComSearchRef" />
	<!-- 按钮 -->
	<slot name="right">
		<a-button type="text" status="info" @click="handleAdd('add')" class="padding0 info">新建</a-button>
	</slot>
</template>
<script lang="ts" setup>
import mitt from "@/utils/bus";
import Breadcrumb from "./Breadcrumb.vue";
defineProps({
	showSearch: {
		type: Boolean,
		default: true
	},
	modelValue: {
		type: String,
		default: ""
	},
	breadCrumb: {
		//面包屑配置
		type: Object,
		default: () => null
	}
});
const route = useRoute();
const emit = defineEmits(["handleBtn", "update:modelValue", "search"]);
const handleAdd = inject("handleAdd");
const ComSearchRef = ref(null);

const handleSearch = (data) => {
	emit("update:modelValue", data);
	emit("search");
	mitt.emit("handleSearch", data);
};
// 删除关键字
mitt.on("handleDelete", (value) => {
	if (ComSearchRef.value) {
		ComSearchRef.value.searchKey = value;
	}
});
</script>
